//
//  RightViewController.m
//  味·道
//
//  Created by lanou3g on 15/6/30.
//  Copyright (c) 2015年 WMR. All rights reserved.
//

#import "RightViewController.h"
#import "MainPageViewController.h"
#import "MenuListViewController.h"
@interface RightViewController ()
@property (nonatomic,retain)MainPageViewController *rootVC;
@end

@implementation RightViewController
- (void)dealloc
{
    self.rootVC = nil;
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // 将页面加载到右视图
    self.rootVC = [[MenuListViewController alloc] init];
    self.rootVC.rightVC = self;//要使用导航控制器
    [self.view addSubview:self.rootVC.view];
    [self.rootVC release];
    
}
//根据传过来的下标决定添加什么样的视图
-(void)addViewWith:(ClassNameModel *)model{
    NSString *className = model.className;
    if ([self.rootVC isMemberOfClass:NSClassFromString(className)]) {
        NSLog(@"重复点击");
    }else{
        [self.rootVC.view removeFromSuperview];
        self.rootVC = nil;
        self.rootVC = [[NSClassFromString(className) alloc] init];
        [self.view addSubview:self.rootVC.view];
        self.rootVC.rightVC = self;
        [self.rootVC release];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
